package com.bitauto.i.commonUtils.arithmetic;

import java.util.ArrayList;
import java.util.List;

/**
 * 输入a1B2，输出所有对应大小写可能
 */
public class LowAndUpperCase {

    public static List<String> getAllCaseCombinations(String input) {
        List<String> result = new ArrayList<>();
        generateCombinations("", input, result);
        return result;
    }

    private static void generateCombinations(String processed, String remaining, List<String> result) {
        if (remaining.isEmpty()) {
            result.add(processed);
            return;
        }

        char firstChar = remaining.charAt(0);
        String rest = remaining.substring(1);

        if (Character.isLetter(firstChar)) {
            // 如果是字母，分别处理小写和大写
            generateCombinations(processed + Character.toLowerCase(firstChar), rest, result);
            generateCombinations(processed + Character.toUpperCase(firstChar), rest, result);
        } else {
            // 如果不是字母（数字），直接添加
            generateCombinations(processed + firstChar, rest, result);
        }
    }

    public static void main(String[] args) {
        String input = "a1B2";
        List<String> output = getAllCaseCombinations(input);
        System.out.println(output);
    }
}
